package com.willen.util;


public class Page {
	
	private int pageNum;
	private int pageSize=5;
	private int totalCount;
	public Page(){}
	public Page(int pageNum,int totalcount){
		setTotalCount(totalcount);
		setPageNum(pageNum);
	}
	public int getStart(){
		return (getPageNum()-1)*getPageSize();
	}
	
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		if(pageNum>getTotalPage()){
			pageNum=getTotalPage();
		}else if(pageNum<1){
			pageNum=1;
		}
		
		this.pageNum = pageNum;
	}
	
	public int getTotalPage(){
		int pages = getTotalCount() / getPageSize();
		if(getTotalCount()%getPageSize()!=0){
			System.out.println("getTotalCount()%getPageSize()="+getTotalCount()%getPageSize());
			return ++pages;
		}else{
			return pages;
		}
	}
	public int getPageSize() {
		return pageSize;
	}
	
	public int getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}
	
	
}
